package com.xhu.rjsx2.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xhu.rjsx2.pojo.PayProject;
import com.xhu.rjsx2.pojo.vo.PageVO;
import com.xhu.rjsx2.service.PayProjectService;
import com.xhu.rjsx2.mapper.PayProjectMapper;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
* @author ZQ
* @description 针对表【pay_project】的数据库操作Service实现
* @createDate 2023-05-08 21:02:40
*/
@Service
public class PayProjectServiceImpl extends ServiceImpl<PayProjectMapper, PayProject>
    implements PayProjectService{

    @Override
    public PageVO listAllPayProjectPage(Integer pageNum, Integer pageSize, String projectName, BigDecimal projectPriceMin, BigDecimal projectPriceMax) {
        LambdaQueryWrapper<PayProject> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(!StrUtil.isBlankIfStr(projectName),PayProject::getProjectName,projectName)
                .ge(!StrUtil.isBlankIfStr(projectPriceMin),PayProject::getProjectPrice,projectPriceMin)
                .le(!StrUtil.isBlankIfStr(projectPriceMax),PayProject::getProjectPrice,projectPriceMax);
        Page<PayProject> page = new Page<>(pageNum,pageSize);
        page(page,queryWrapper);
        return new PageVO(page.getRecords(), page.getTotal());
    }
}




